#pragma once

#include <QtWidgets/QWidget>
#include "ui_ColorMap.h"
#include <AudioDecode\Decoders.h>
#include <AudioDecode\AudioFFT.h>
#include <complex>
#include "Player.h"
#include <thread>
#include "CalcProgress.h"
#include "MultiEqualization.h"

using namespace audio;
struct ColorPoint
{
	double x, y, z;
};
class ColorMap : public QWidget
{
    Q_OBJECT

public:
    ColorMap(QWidget *parent = Q_NULLPTR);

signals:
	void calcProgress(unsigned int , unsigned int );
private:
    Ui::ColorMapClass ui;
	void ConnectSlots();
	void importWav();
	void releaseAudioData();


	void ShowTimeData();
	void ShowFreqData();
	void ShowColormap();
	void autoRange(QCustomPlot * gplot);
	void initBar();
	void initColorMap();
	void setBarData(const std::vector<float> &data);
	void Play();
	void Stop();
	void hanning(double* w, long nf);
	void onDynamicChanged();
	void onMaxChanged();
	void CalcColorData();
	void showCalcProgress(unsigned int value, unsigned int Count);
	void setFilterArgs();
	void showEqWidget();
	void onEqArgsChanged(unsigned int count, unsigned int freq, int gain);

	AudioData *m_audio_data = NULL;
	QCPColorMap *m_colorMap;
	std::thread m_thread;
	QCPBars *m_regen;
	QCPColorScale *colorScale;
	Player m_player;
	std::vector<ColorPoint> m_color_data;
	CalcProgress calc_ui;
	MultiEqualization eq;
};
